<template>
  <header class="header">
    <h1>todos</h1>
    <input v-model="isAll" id="toggle-all" class="toggle-all" type="checkbox" />
    <label for="toggle-all"></label>
    <input
      class="new-todo"
      placeholder="输入任务名称-回车确认"
      autofocus
      ref="ipt"
      @keydown.enter="enterDown"
    />
  </header>
</template>

<script>
import {mapState} from "vuex"
export default {
  data() {
    return {
     
    };
  },
 methods:{
   enterDown(){
      this.$store.commit('todo/addState', {
        value:this.$refs.ipt.value
      });
   }
   
 },
 computed:{
   ...mapState('todo',['list']),
   isAll:{
     set(val){
       this.$store.commit("todo/updateAllState",val)
     },
     get(){
       return this.list.every((item) => item.done);
     }
   }
 }
};
</script>